package com.tencreat.service.mall.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tencreat.common.core.domain.model.ReqIdParam;
import com.tencreat.common.core.domain.model.ReqIdsParam;
import com.tencreat.domain.mall.MallPaySetting;
import com.tencreat.mapper.mall.MallPaySettingMapper;
import com.tencreat.service.mall.IMallPaySettingService;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * 支付设置Service业务层处理
 *
 * @Author tencreat
 * @Company: 深圳腾创互联科技有限公司
 * @link: https://tencreat.com
 * @Date 2022-07-07
 */
@Service
public class MallPaySettingServiceImpl extends ServiceImpl<MallPaySettingMapper, MallPaySetting> implements IMallPaySettingService {


    /**
     * 查询支付设置
     *
     * @param id 支付设置ID
     * @return 支付设置
     */
    @Override
    public MallPaySetting selectMallPaySettingById(ReqIdParam id) {
        return baseMapper.selectById(id.getId());
    }

    /**
     * 查询支付设置列表
     *
     * @param mallPaySetting 支付设置
     * @return 支付设置
     */
    @Override
    public List<MallPaySetting> selectMallPaySettingList(MallPaySetting mallPaySetting) {
        return baseMapper.selectList(Wrappers.query(mallPaySetting));
    }

    /**
     * 新增支付设置
     *
     * @param mallPaySetting 支付设置
     * @return 结果
     */
    @Override
    public int insertMallPaySetting(MallPaySetting mallPaySetting) {
        mallPaySetting.setCreateTime(LocalDateTime.now());
        return baseMapper.insert(mallPaySetting);
    }

    /**
     * 修改支付设置
     *
     * @param mallPaySetting 支付设置
     * @return 结果
     */
    @Override
    public int updateMallPaySetting(MallPaySetting mallPaySetting) {
        mallPaySetting.setUpdateTime(LocalDateTime.now());
        return baseMapper.updateById(mallPaySetting);
    }

    /**
     * 批量删除支付设置
     *
     * @param ids 需要删除的支付设置ID
     * @return 结果
     */
    @Override
    public int deleteMallPaySettingByIds(ReqIdsParam ids) {
        return baseMapper.deleteBatchIds(ids.getId());
    }

    /**
     * 删除支付设置信息
     *
     * @param id 支付设置ID
     * @return 结果
     */
    @Override
    public int deleteMallPaySettingById(ReqIdParam id) {
        return baseMapper.deleteById(id.getId());
    }
}
